import random
import math

def Dist(Loc1, Loc2):
    return math.sqrt((Loc1[0] - Loc2[0])*(Loc1[0] - Loc2[0])+(Loc1[1] - Loc2[1])*(Loc1[1] - Loc2[1]))


c = [40,50,100,100,100,200,200,300,400,400]
f = [30,30,20,40,60,50,100,120,100,120]

s = 'grid'
for rep in range(0, 10):
    for num in range(0, 10):
        filename = s + "\\%d\\%d"%(num, rep) + ".txt"
        fl = open(filename, 'w')
        F = []
        C = []
        for i in range(0, f[num]):
            F.append([random.randint(0,10000), random.randint(0,10000)])
        for j in range(0, c[num]):
            C.append([random.randint(0,10000), random.randint(0,10000)])
        fl.write("%d %d\n"%(f[num],c[num]))
        
        for i in range(0, f[num] - 1):
            fl.write("%d "%random.randint(1,9999))
        fl.write("%d\n"%random.randint(1,9999))
        
        for i in range(0, f[num] - 1):
            fl.write("%d "%random.randint(1,int(math.sqrt(c[num]))))
        fl.write("%d\n"%random.randint(1,int(math.sqrt(c[num]))))

        for j in range(0, c[num] - 1):
            fl.write("%d "%random.randint(0,20000))
        fl.write("%d\n"%random.randint(0,20000))

        for i in range(0, f[num]):
            for j in range(0, c[num] - 1):
                fl.write("%f "%Dist(F[i],C[j]))
            fl.write("%f\n"%Dist(F[i],C[-1]))
        fl.close()
